#ifndef FIELD2D_H
#define FIELD2D_H

#include <cmath>

#include <vector>
#include <iostream>

#include "../Field/Field.h"

using namespace std;

template<class Type>
class Field2D : public Field<Type>
{

public:
    Field2D();

    Field2D( std::vector<int> dims );

    Field2D( std::vector<int> dims, std::string name );

    ~Field2D();

    void allocate_dims(std::vector<int> dims );


    inline Type& operator () (int i,int j)
    {
        PICDEBUGEXECUTE(if (i>=dims_[0] || j>=dims_[1]) log_error<<name << "Out of limits & "<< i << " " << j;);
        PICDEBUGEXECUTE(if (!std::isfinite(data_2D[i][j])) log_error<<name << " Not finite "<< i << "," << j << " = " << data_2D[i][j];);
        return data_2D[i][j];
    };


    inline Type operator () (int i,int j) const
    {
        PICDEBUGEXECUTE(if (i>=dims_[0] || j>=dims_[1]) log_error<<name << "Out of limits "<< i << " " << j;);
        PICDEBUGEXECUTE(if (!std::isfinite(data_2D[i][j])) log_error<<name << "Not finite "<< i << "," << j << " = " << data_2D[i][j]);
        return data_2D[i][j];
    };

    Field2D& operator=(const Field2D& field2D);

    Type** data_2D;

private:

};

#endif
